<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<% response.setContentType("text/html; charset=UTF-8");%>
<% request.setCharacterEncoding("utf-8");%>
<%@ page import="java.sql.*" %>
<%@ page import="javax.xml.parsers.*" %>
<%@ page import="org.w3c.dom.*" %>
<%@ page import="java.io.File" %>
<%
	Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(getServletContext().getRealPath("/") + "web.xml"));
	doc.getDocumentElement().normalize();
	String dbhost = doc.getElementsByTagName("host").item(0).getTextContent();
	String dbport = doc.getElementsByTagName("port").item(0).getTextContent();
	String dbuser = doc.getElementsByTagName("user").item(0).getTextContent();
	String dbpass = doc.getElementsByTagName("pass").item(0).getTextContent();
	String dbname = doc.getElementsByTagName("database").item(0).getTextContent();
	String dbconnString = "jdbc:mysql://" + dbhost + ":" + dbport + "/" + dbname + "?setUnicode=true&characterEncoding=UTF-8";
	Class.forName("com.mysql.jdbc.Driver").newInstance();
	Connection dbconn = DriverManager.getConnection(dbconnString, dbuser, dbpass);
	Statement query = dbconn.createStatement();
%>

<%
	ResultSet rs = query.executeQuery("select * from loaidethi order by maLDT asc");
	while (rs.next()) {
		out.println("<div class='item " + Integer.toString(rs.getInt("maLDT"))
			+ "' onclick=\" dethi_load('" + Integer.toString(rs.getInt("maLDT")) + "'); \" >");
		
		out.println("<div class='header'>Loại đề thi : <b>");
		out.println(rs.getString("tenloai"));
		out.println("</b></div>");
		
		out.println("<div class='info'>Thời gian làm bài : <b>");
		out.println(Integer.toString(rs.getInt("thoigian")));
		out.println("  phút</b></div>");
		
		out.println("<div class='info'>Số câu hỏi dễ : <b>");
		out.println(Integer.toString(rs.getInt("socaude")));
		out.println("</b></div>");
		
		out.println("<div class='info'>Số câu hỏi trung bình : <b>");
		out.println(Integer.toString(rs.getInt("socautb")));
		out.println("</b></div>");
		
		out.println("<div class='info'>Số câu hỏi khó : <b>");
		out.println(Integer.toString(rs.getInt("socaukho")));
		out.println("</b></div>");
		
		out.println("</div>");
	}
	rs.close();
%>

<% dbconn.close();%>